package com.huatai.exchange.impl;

import com.faneui.common.exception.BusinessException;
import com.huatai.exchange.dal.dao.ExcCommunicationDAO;
import com.huatai.exchange.dal.model.ExcCommunication;
import com.huatai.exchange.dal.model.ExcExchangeInfo;
import com.huatai.exchange.service.ExcCommunicationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ExcCommunicationServiceImpl implements ExcCommunicationService {

    @Autowired
    private ExcCommunicationDAO excCommunicationDAO ;

    @Override
    public List<ExcCommunication> queryExcCommunicationList(ExcCommunication excCommunication) throws BusinessException {
        List<ExcCommunication> communications = null;
        try{
            communications = excCommunicationDAO.queryByModel(excCommunication) ;
        }catch (Exception ex) {
            BusinessException.throwBusinessException(ex);
        }
        return communications;
    }

    @Override
    public List<ExcCommunication> queryExcCommunicationList(String exchangeInfoId) throws BusinessException {
        ExcCommunication param = new ExcCommunication();
        param.setExchangeInfoId(exchangeInfoId);
        return queryExcCommunicationList(param) ;
    }

    @Override
    public void addExcCommunication(ExcCommunication excCommunication) throws BusinessException {
        try{
            excCommunicationDAO.insert(excCommunication);
        }catch (Exception ex) {
            BusinessException.throwBusinessException(ex);
        }
    }

    @Override
    public void modifyExcCommunication(ExcCommunication excCommunication) throws BusinessException {
        try{
            excCommunicationDAO.updateById(excCommunication) ;
        }catch (Exception ex) {
            BusinessException.throwBusinessException(ex);
        }
    }

    @Override
    public void deleteExcCommunication(String id) throws BusinessException {
        try{
            excCommunicationDAO.deleteById(id) ;
        }catch (Exception ex) {
            BusinessException.throwBusinessException(ex);
        }
    }
}
